package com.maket.scxx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.maket.scxx.domain.WlMaterialsAndMesBom;
import com.maket.scxx.service.IWlMaterialsAndMesBomService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

/**
 * 物料与BOMController
 * 
 * @author ruoyi
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/bomMore")
public class WlMaterialsAndMesBomController extends BaseController
{
    @Autowired
    private IWlMaterialsAndMesBomService wlMaterialsAndMesBomService;

    /**
     * 查询物料与BOM列表
     */
    @RequiresPermissions("scxx:bomMore:list")
    @GetMapping("/list")
    public AjaxResult list(WlMaterialsAndMesBom wlMaterialsAndMesBom)
    {
        List<WlMaterialsAndMesBom> list = wlMaterialsAndMesBomService.selectWlMaterialsAndMesBomList(wlMaterialsAndMesBom);
        return success(list);
    }

    /**
     * 导出物料与BOM列表
     */
    @RequiresPermissions("scxx:bomMore:export")
    @Log(title = "物料与BOM", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WlMaterialsAndMesBom wlMaterialsAndMesBom)
    {
        List<WlMaterialsAndMesBom> list = wlMaterialsAndMesBomService.selectWlMaterialsAndMesBomList(wlMaterialsAndMesBom);
        ExcelUtil<WlMaterialsAndMesBom> util = new ExcelUtil<WlMaterialsAndMesBom>(WlMaterialsAndMesBom.class);
        util.exportExcel(response, list, "物料与BOM数据");
    }

    /**
     * 获取物料与BOM详细信息
     */
    @RequiresPermissions("scxx:bomMore:query")
    @GetMapping(value = "/{wId}")
    public AjaxResult getInfo(@PathVariable("wId") Long wId)
    {
        return success(wlMaterialsAndMesBomService.selectWlMaterialsAndMesBomByWId(wId));
    }

    /**
     * 新增物料与BOM
     */
    @RequiresPermissions("scxx:bomMore:add")
    @Log(title = "物料与BOM", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WlMaterialsAndMesBom wlMaterialsAndMesBom)
    {
        return toAjax(wlMaterialsAndMesBomService.insertWlMaterialsAndMesBom(wlMaterialsAndMesBom));
    }

    /**
     * 修改物料与BOM
     */
    @RequiresPermissions("scxx:bomMore:edit")
    @Log(title = "物料与BOM", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WlMaterialsAndMesBom wlMaterialsAndMesBom)
    {
        return toAjax(wlMaterialsAndMesBomService.updateWlMaterialsAndMesBom(wlMaterialsAndMesBom));
    }

    /**
     * 删除物料与BOM
     */
    @RequiresPermissions("scxx:bomMore:remove")
    @Log(title = "物料与BOM", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wId}")
    public AjaxResult remove(@PathVariable Long wId)
    {
        return toAjax(wlMaterialsAndMesBomService.deleteWlMaterialsAndMesBomByWId(wId));
    }
}
